﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DataAccessLayer;
using BussinessLayer;

namespace QLBaoHanh.NghiepVu
{
    public partial class frmGiaoNhanVienThucHien : Form
    {
        private int _phienId;
        private frmDsPhienTheoTrangThai _callerForm;
        public frmGiaoNhanVienThucHien(int inPhienId, frmDsPhienTheoTrangThai inCallerForm)
        {
            InitializeComponent();
            _phienId = inPhienId;
            _callerForm = inCallerForm;
        }
        private frmGiaoNhanVienThucHien()
        {
            InitializeComponent();
        }
        private void LoadForm()
        {
            // Fill combobox nhan vien thuc hien
            cboNhanVienThucHien.DataSource = NhanVienBO.getInstance.GetAllNhanVien();
            cboNhanVienThucHien.DisplayMember = "Ten";
            cboNhanVienThucHien.ValueMember = "Id";
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            Phien_NhanVienThucHien obj = new Phien_NhanVienThucHien();
            obj.PhienId = _phienId;
            obj.NhanVienId = (int)cboNhanVienThucHien.SelectedValue;
            obj.ThoiDiemGiao = dtpNgayGiao.Value;
            obj.GhiChu = txtGhiChu.Text;
            Phien_NhanVienThucHienBO.getInstance.InsertPhien_NhanVienThucHien(obj);
            _callerForm.RefreshGridNhanVienThucHien();
            this.Close();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmGiaoNhanVienThucHien_Load(object sender, EventArgs e)
        {
            LoadForm();
        }
    }
}
